//
//  map.h
//  map-matching
//
//  Created by Lv Xin on 16/4/11.
//  Copyright © 2016年 Lv Xin. All rights reserved.
//

#ifndef map_h
#define map_h

#include "constNum.h"
#include "node.h"
#include "edge.h"
#include <stdio.h>
#include <vector>

struct Grid{
    std::vector<Node> node;
    std::vector<Edge> edge;
};

struct DoublePos{
    double lat, lng;
    static double getTwoPosDis(DoublePos a, DoublePos b);
};

struct IntPos{
    int x, y;
};

class Map{
public:
    Grid** grid;
    Node node[MAX_NODE];
    Edge edge[MAX_EDGE];
    int gridX, gridY, nodeSum, edgeSum;
public:
    Map();
    ~Map();
    DoublePos convertToDoublePos(int x, int y);
    IntPos convertToIntPos(double lat, double lng);
    DoublePos convertToGridPos(double lat, double lng);
    std::vector<Edge> getAllEdgeInOneGrid(double lat, double lng);
    void addNode(double lat, double lng, Node& node);
    void addEdge(double lat, double lng, Edge& edge);
    void fileAddNode(std::string);
    void fileAddEdge(std::string);
};

#endif /* map_h */
